<?php
declare (strict_types = 1);

namespace app\sms\controller;

use app\BaseController;
use app\sms\service\SmsService;

class Api extends BaseController
{
    /**
     * 发送短信
     *
     * @Author tanruizheng
     * @DateTime 2021-08-26
     * @return void
     */
    public function sendSms(){
        try {
            $config = [
                'platform' => [
                   SmsService::ALIYUN,//阿里云
                //    SmsService::TENCENT//腾讯云
                ],
                'config' => [
                    SmsService::ALIYUN => [
                        'access_id'     => 'LTAI4FgF7fTJtErKouoAGXRo',
                        'access_key'    => '0kc8uRomHltgds0Qu2DgYR46Wi3KeG',
                        'sign'          => 'crmeb',
                        'templateCode'  => '11',
                        'templateParam' => [],
                    ],
                    SmsService::TENCENT => [
                        'access_id'     => 'AKIDnOkqfDUUDfqjMinb9PO6XibHgofEWYJn ',
                        'access_key'    => 'EBrHPGrACxReaFdkcDWZKo1xc07xWrvi',
                        'sign'          => 'cms内容管理系统',
                        'smsSdkAppId'   => 1400565961,
                        'templateCode'  => '11',
                        'templateParam' => [],
                    ]
                ]
            ];
            $smsService = new SmsService($config);
            $res = $smsService->sendSms('13763017217');
            return json($res);
        } catch (\Exception $e) {
            return self::createFail($e->getMessage());
        }
       
    }
}
